var entityId = quoteForeignId;
var url = window.rootPath + '/ui/task/' + taskId;
jQuery('.app-btn-pass').on('click', function() {
	jQuery('#loadingImage').show();
	jQuery.ajax({
		url : encodeURI(url),
		method : "post",
		data : JSON.stringify({
			"auditState" : "通过",
			"auditAdvice" : jQuery('#auditAdvice').val(),
			"taskId" : taskId

		}),
		contentType : 'application/json;charset=utf-8',
		dataType : 'json',
		success : function() {
			jQuery('#loadingImage').hide();
			window.location = window.rootPath + '/ui/index';
		}
	});
});
jQuery('.app-btn-reject').on('click', function() {
	jQuery('#loadingImage').show();
	jQuery.ajax({
		url : encodeURI(url),
		method : "post",
		data : JSON.stringify({
			"auditState" : "驳回",
			"auditAdvice" : jQuery('#auditAdvice').val(),
			"taskId" : taskId
		}),
		contentType : 'application/json;charset=utf-8',
		dataType : 'json',
		success : function(data) {
			jQuery('#loadingImage').hide();
			window.location = window.rootPath + '/ui/index';
		}
	});
});

// 泵table
var serverData = {};
serverData.quoteForeignId = jQuery("#id").val();
var serverTable;
jQuery(document)
		.ready(
				function() {
					var isPump = 'true';
					serverTable = jQuery('#mainDeviceTable')
							.DataTable(
									{
										"serverSide" : true,
										"ordering" : false,
										"ajax" : {
											"dataType" : "json",
											"type" : "get",
											"cache" : false,
											"url" : window.rootPath
													+ '/ui/quote-foreign/getMainpage'
													+ '?isPump=' + isPump,
											"data" : function(d) {
												return $.extend({}, d,
														serverData);
											}
										},
										columns : [ {
											data : null,
											defaultContent : ""
										}, {
											data : 'productName'
										}, {
											data : 'productType'
										}, {
											data : 'productModel'
										}, 
										{
						                	data: null,
						                	 render: function (data, type, full, meta) {
							                        var dOut;
							                        if (data.isInventory == "1") {
														dOut = '<td class="center" ><span class="badge label-pill label-primary">降库产品</span></td>';
													} else if (data.isInventory == "2"){
														dOut = '<td class="center" ><span class="badge label-pill label-success">被降库</span></td>';
													}else{
														dOut = '<td class="center" ><span class="badge label-pill label-danger">未降库</span></td>';
													}             
							                        return dOut;
							                    }
						                },
										{
											data : 'number'
										}, 
										{
											data : 'unit'
										},
										{
											data : 'costPrice'
										},
										{
											data : 'unitPrice'
										}, {
											data : 'power'
										}, {
											data : 'flowMaterial'
										}, {
											data : 'transMedia'
										}, {
											data : 'viscosity'
										}, {
											data : 'flux'
										}, {
											data : 'pumpLift'
										}, {
											data : 'temperature'
										}, {
											data : 'proportion'
										}, {
											data : 'inPressure'
										}, {
											data : 'effectiveNPSHA'
										}, {
											data : 'mustMPSHA'
										} ],
										"drawCallback" : function(oSettings) {
											var k = 0;
											var total = oSettings.aiDisplay.length
													+ oSettings._iDisplayStart;
											for (var i = oSettings._iDisplayStart, iLen = total; i < iLen; i++) {
												$(
														'td:eq(0)',
														oSettings.aoData[oSettings.aiDisplay[k]].nTr)
														.text(i + 1);
												k++;
											}

										}
									});

				});

// 其他table
var serverData1 = {};
var serverTable1;
serverData1.quoteForeignId = jQuery("#id").val();
jQuery(document)
		.ready(
				function() {
					serverTable1 = jQuery('#otherTable')
							.DataTable(
									{
										"serverSide" : true,
										"ordering" : false,
										"ajax" : {
											"dataType" : "json",
											"type" : "get",
											"cache" : false,
											"url" : window.rootPath
													+ '/ui/quote-foreign/getOtherpage',
											"data" : function(d) {
												return $.extend({}, d,
														serverData1);
											}
										},
										columns : [ {
											data : null,
											defaultContent : ""
										}, {
											data : 'deviceName'
										}, {
											data : 'type'
										},
										{
											data: 'material'
										},
										{
											data : 'unit'
										}, {
											data : 'amount'
										},
										{
											data : 'costPrice'
										},
										{
											data : 'price'
										} ],
										"drawCallback" : function(oSettings) {
											var k = 0;
											var total = oSettings.aiDisplay.length
													+ oSettings._iDisplayStart;
											for (var i = oSettings._iDisplayStart, iLen = total; i < iLen; i++) {
												$(
														'td:eq(0)',
														oSettings.aoData[oSettings.aiDisplay[k]].nTr)
														.text(i + 1);
												k++;
											}
										}
									});

				});

// 查看附件
jQuery('.attachment').on('click', function() {
	var quoteForeignId = jQuery("#id").val();
	filedown(quoteForeignId, '外贸价格单附件', 0);
});
////获附件数量
var quoteForeignId=jQuery("#id").val();
var numId='foreign-quote-ANum';
if(quoteForeignId!=''){
	showANum(quoteForeignId,'外贸价格单附件',numId);
}
